<template>
  <div class="">
    <!-- 确认订单页面 -->
    <van-contact-card
      type="edit"
      :name="defaultAddress.linkMan"
      :tel="defaultAddress.mobile"
      @click="$router.push('/addresslist')"
    />

    <div class="title">商品列表</div>

    <van-card
      v-for="item in list"
      :key="item.id"
      :num="item.num"
      :price="item.price"
      :desc="item.properties"
      :title="item.title"
      :thumb="item.img"
    >
    </van-card>
  </div>
</template>

<script>
import { ref, reactive, toRefs, computed } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";

import { getDefaultAdress } from "../../utils/shopcar.js";
//引入获取默认地址的接口
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      defaultAddress: "",
    });
    const list = computed(() => {
      return store.state.shopcar.filter((item) => item.status == true);
    });
    //把选中的商品筛选出来
    getDefaultAdress().then((res) => {
      console.log(res);
      if (res.code == 0) {
        data.defaultAddress = res.data;
      }
    });

    return { ...toRefs(data), list };
  },
};
</script>

<style lang="scss" scoped>
.title {
  height: 50px;
  border-bottom: 2px solid #e8e8e8;
  line-height: 50px;
  padding-left: 20px;
  box-sizing: border-box;
  font-size: 14px;
}
</style>
